<?php

namespace app\api\validate;

use app\api\validate\BaseValidate;

/**
 * @Author: suyuan
 * @Email: 819067126@qq.com
 * @Date: 2020/12/01 11:32
 */

 class IDCollection extends BaseValidate
 {
     protected $rule = [
        'ids' => 'require|IDsCheck',
     ];

     protected $message = [
         'ids' => 'ids必须是以逗号分隔的多个正整数'
     ];


     protected function IDsCheck($value)
     {
         $ids = explode(',', $value);
         if (empty($ids)) {
             return false;
         }
         foreach ($ids as $id) {
             if (!$this->isPositiveInteger($id)) {
                 return false;
             }
         }
         return true;
     }
 }
